package com.aseo.business.hibernate;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.aseo.model.dao.Dao;
import com.aseo.model.entity.hibernate.Chofer;
import com.aseo.model.entity.hibernate.RecorridoVehiculo;
import com.aseo.model.entity.hibernate.Vehiculo;

@Service
public class RecorridoVehiculoManager implements ManagerInterface<RecorridoVehiculo> {

	@Resource  
	private Dao dao;
	
	@Override
	public List<RecorridoVehiculo> getAll() {
		final List<RecorridoVehiculo> list = dao.find(RecorridoVehiculo.class);  
	    return list;
	}

	@Override
	public void persist(RecorridoVehiculo t) {
		dao.persist(t);
	}
	
	public List<RecorridoVehiculo> getByVehiculoChofer(Vehiculo vehiculo, Chofer chofer, Integer fecha) {
		final List<RecorridoVehiculo> list = dao.find(" SELECT recorridoVehiculo " +
                                                      " FROM com.aseo.model.entity.hibernate.RecorridoVehiculo recorridoVehiculo " +
                                                      " WHERE recorridoVehiculo.choferId.choferId = " + chofer.getChoferId() +
                                                      " AND recorridoVehiculo.vehiculoId.vehiculoId = " + vehiculo.getVehiculoId() + 
                                                      " AND recorridoVehiculo.fechaRecorrido = " + fecha);
	    return list;
	}

}
